package cn.zhl.lambda;

import lombok.Builder;
import lombok.Data;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-04-18 11:35
 **/
@Data
@Builder
public class Person {
	private String nj;
	private String bj;
	private String zu;
	private String name;
	private int age;
	private int score;

	public static void main(String[] args) {
		Person xm = Person.builder().name("小明").build();
		xm.say(s -> {
			System.out.println("大家好,我叫" + s);
		});
		//方法引用，表示一个lambda表达式
		xm.say(System.out::println);
	}

	@Override
	public String toString() {
		return nj + ":" + bj + ":" + zu + ":" + name + ":" + age + ":" + score;
	}

	public String info(String pre) {
		return pre + "my name is " + name + ",my age is " + age;
	}

	public void say(SpeakInterface<String> si) {
		System.out.println("before===");
		si.say(name);
		System.out.println("after===");
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		return name.equals(((Person) obj).getName());
	}

}
